/**
 * Author@ Cheng Feitian
 * Date: 2020-3-23
 * Description: 封装案例-立方体设计
 */

#include <algorithm>
#include <iostream>
#include <string>

using namespace std;
const int maxn = 1024;

/**
 * @brief 立方体类设计
 * 1.创建立方体类
 * 2.设计属性
 * 3.设计行为 获取立方体面积和体积
 * 4.分别利用全局函数和成员函数 判断两个立方体是否相等
 */
class Cube
{
private:
    int m_Long;
    int m_Weight;
    int m_Height;

public:
    void setLong(int Long)
    {
        m_Long = Long;
    }
    int getLong()
    {
        return m_Long;
    }
    void setWeight(int Weight)
    {
        m_Weight = Weight;
    }
    int getWeight()
    {
        return m_Weight;
    }
    void setHeight(int Height)
    {
        m_Height = Height;
    }
    int getHeight()
    {
        return m_Height;
    }

    //获取立方体面积
    int calculateS()
    {
        return 2 * (m_Long * m_Weight + m_Long * m_Height + m_Weight * m_Height);
    }
    //获取立方体体积
    int calculateV()
    {
        return m_Long * m_Weight * m_Height;
    }

    //成员函数判断是否相等
    bool isSamebyClass(Cube &c)
    {
        bool status;
        if ((m_Long == c.getLong()) && (m_Weight == c.getWeight()) && (m_Height == c.getHeight()))
        {
            status = true;
        }
        else
            status = false;
        return status;
    }
};

bool isSame(Cube &c1, Cube &c2)
{
    bool status;
    if ((c1.getLong() == c2.getLong()) && (c1.getWeight() == c2.getWeight()) && (c1.getHeight() == c2.getHeight()))
    {
        status = true;
    }
    else
        status = false;
    return status;
}

int main()
{
    Cube c1;
    c1.setHeight(10);
    c1.setLong(10);
    c1.setWeight(10);

    cout << "c1的面积为：" << c1.calculateS() << endl;
    cout << "c1的面积为：" << c1.calculateV() << endl;

    Cube c2;
    c2.setHeight(10);
    c2.setLong(10);
    c2.setWeight(10);

    bool ret = isSame(c1, c2);
    if (ret)
    {
        cout << "两个立方体相等" << endl;
    }
    else
    {
        cout << "两个立方体不等" << endl;
    }

    ret = c1.isSamebyClass(c2);
    if (ret)
    {
        cout << "成员函数判断:两个立方体相等" << endl;
    }
    else
    {
        cout << "成员函数判断:两个立方体不等" << endl;
    }

    return 0;
}
